home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / TIPS / PRINT_IT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-10-09  |  2KB  |  92 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Tips & Techniques Demo Program               }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program Print_It;
  10.  
  11. {$R Print_It}
  12.  
  13. uses WinTypes, WinProcs, WObjects, Strings, WinPrint;
  14.  
  15. const
  16.   cm_Print = 100;
  17.   cm_SelPrint = 101;
  18.   cm_ConfigPrint = 102;
  19.  
  20. type
  21.   PMainWindow = ^TMainWindow;
  22.   TMainWindow = object(TWindow)
  23.     PI: PPrinterInfo;
  24.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  25.     procedure SetUpWindow; virtual;
  26.     destructor Done; virtual;
  27.     procedure CMPrint(var Msg: TMessage);
  28.       virtual cm_First + cm_Print;
  29.     procedure CMSelPrint(var Msg: TMessage);
  30.       virtual cm_First + cm_SelPrint;
  31.     procedure CMConfigPrint(var Msg: TMessage);
  32.       virtual cm_First + cm_ConfigPrint;
  33.   end;
  34.  
  35. constructor TMainWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  36. begin
  37.   TWindow.Init(AParent, ATitle);
  38.   Attr.Menu:=LoadMenu(HInstance, 'MAINMENU');
  39. end;
  40.  
  41. procedure TMainWindow.SetUpWindow;
  42. begin
  43.   TWindow.SetUpWindow;
  44.   new(PI, init);
  45. end;
  46.  
  47. destructor TMainWindow.Done;
  48. begin
  49.   TWindow.Done;
  50.   dispose(PI, done);
  51. end;
  52.  
  53. procedure TMainWindow.CMPrint(var Msg: TMessage);
  54. begin
  55.   with PI^ do
  56.   begin
  57.     StartDoc('HardCopy');
  58.     NewFrame;
  59.     TextOut(PrintDC, 10, 10, 'Printing from PRINT_IT.PAS.', 24);
  60.     Rectangle(PrintDC, 100, 100, 300, 300);
  61.     NewFrame;
  62.     EndDoc;
  63.   end;
  64. end;
  65.  
  66. procedure TMainWindow.CMSelPrint(var Msg: TMessage);
  67. begin
  68.   PI^.SelectPrinter;
  69. end;
  70.  
  71. type
  72.   TApp = object(TApplication)
  73.     procedure InitMainWindow; virtual;
  74.   end;
  75.  
  76. procedure TMainWindow.CMConfigPrint(var Msg: TMessage);
  77. begin
  78.   PI^.DeviceMode;
  79. end;
  80.  
  81. procedure TApp.InitMainWindow;
  82. begin
  83.   MainWindow:=new(PMainWindow, Init(nil, 'Print_It'));
  84. end;
  85.  
  86. var
  87.   App: TApp;
  88. begin
  89.   App.Init('Print_It');
  90.   App.Run;
  91.   App.Done;
  92. end.